package com.taobao.api.request;

import java.util.Date;
import java.util.Map;

import com.taobao.api.ApiRuleException;
import com.taobao.api.TaobaoRequest;
import com.taobao.api.internal.util.RequestCheckUtils;
import com.taobao.api.internal.util.TaobaoHashMap;
import com.taobao.api.response.TradesSoldIncrementGetResponse;

/**
 * TOP API: taobao.trades.sold.increment.get request
 * 
 * @author auto create
 * @since 1.0, 2013-07-21 16:38:14
 */
public class TradesSoldIncrementGetRequest implements TaobaoRequest<TradesSoldIncrementGetResponse> {

  private Map<String, String> headerMap = new TaobaoHashMap();
  private TaobaoHashMap       udfParams;                      // add
                                                              // user-defined
                                                              // text parameters
  private Long                timestamp;

  /**
   * 查询修改结束时间，必须大于修改开始时间(修改时间跨度不能大于一天)，格式:yyyy-MM-dd HH:mm:ss。<span style=
   * "color:red;font-weight: bold;">建议使用30分钟以内的时间跨度，能大大提高响应速度和成功率</span>。
   */
  private Date                endModified;

  /**
   * 可选值有ershou(二手市场的订单）,service（商城服务子订单）mark（双十一大促活动异常订单）
   * 作为扩展类型筛选只能做单个ext_type查询，不能全部查询所有的ext_type类型
   */
  private String              extType;

  /**
   * 需要返回的字段。目前支持有： 1.Trade中可以指定返回的fields:seller_nick, buyer_nick, title, type,
   * created, tid, seller_rate,seller_can_rate, buyer_rate,can_rate,status,
   * payment, discount_fee, adjust_fee, post_fee, total_fee, pay_time, end_time,
   * modified, consign_time, buyer_obtain_point_fee, point_fee, real_point_fee,
   * received_payment,pic_path, num_iid, num, price, cod_fee, cod_status,
   * shipping_type, receiver_name, receiver_state, receiver_city,
   * receiver_district, receiver_address, receiver_zip, receiver_mobile,
   * receiver_phone,alipay_id,alipay_no,is_lgtype,is_force_wlb,is_brand_sale,
   * has_buyer_message,credit_card_fee,step_trade_status,step_paid_fee,
   * mark_desc,send_time,,has_yfx,yfx_fee,yfx_id,yfx_type,trade_source,
   * seller_flag,is_daixiao 2.Order中可以指定返回fields： orders.title, orders.pic_path,
   * orders.price, orders.num, orders.num_iid, orders.sku_id,
   * orders.refund_status, orders.status, orders.oid, orders.total_fee,
   * orders.payment, orders.discount_fee, orders.adjust_fee,
   * orders.sku_properties_name, orders.item_meal_name, orders.buyer_rate,
   * orders.seller_rate, orders.outer_iid, orders.outer_sku_id,
   * orders.refund_id, orders.seller_type，orders.end_time,
   * orders.order_from,orders.consign_time,orders.shipping_type,orders.
   * logistics_company,orders.invice_no,orders.is_daixiao
   * 3.fields：orders（返回Order的所有内容） 4.fields:service_orders(返回service_order中所有内容)
   */
  private String              fields;

  /**
   * 默认值为false，表示按正常方式查询订单；如果设置为true则查询到的是模糊后的订单列表，可通过模糊订单列表中的buyer_nick/
   * buyer_id字段与流量数据进行关联。如果没有使用流量数据接口请忽略本字段。
   */
  private Boolean             isAcookie;

  /**
   * 页码。取值范围:大于零的整数;默认值:1。<span style=
   * "color:red;font-weight: bold;" >注：必须采用倒序的分页方式（从最后一页往回取）才能避免漏单问题。</span>
   */
  private Long                pageNo;

  /**
   * 每页条数。取值范围：1~100，默认值：40。<span style=
   * "color:red;font-weight: bold;" >建议使用40~50，可以提高成功率，减少超时数量</span>。
   */
  private Long                pageSize;

  /**
   * 查询修改开始时间(修改时间跨度不能大于一天)。格式:yyyy-MM-dd HH:mm:ss
   */
  private Date                startModified;

  /**
   * 交易状态，默认查询所有交易状态的数据，除了默认值外每次只能查询一种状态。 可选值 TRADE_NO_CREATE_PAY(没有创建支付宝交易)
   * WAIT_BUYER_PAY(等待买家付款) SELLER_CONSIGNED_PART（卖家部分发货）
   * WAIT_SELLER_SEND_GOODS(等待卖家发货,即:买家已付款)
   * WAIT_BUYER_CONFIRM_GOODS(等待买家确认收货,即:卖家已发货) TRADE_BUYER_SIGNED(买家已签收,货到付款专用)
   * TRADE_FINISHED(交易成功) TRADE_CLOSED(交易关闭) TRADE_CLOSED_BY_TAOBAO(交易被淘宝关闭)
   * ALL_WAIT_PAY(包含：WAIT_BUYER_PAY、TRADE_NO_CREATE_PAY)
   * ALL_CLOSED(包含：TRADE_CLOSED、TRADE_CLOSED_BY_TAOBAO)
   */
  private String              status;

  /**
   * 卖家对交易的自定义分组标签，目前可选值为：time_card（点卡软件代充），fee_card（话费软件代充）
   */
  private String              tag;

  /**
   * 交易类型列表，同时查询多种交易类型可用逗号分隔。<span style=
   * "color:red;font-weight: bold;" >默认同时查询guarantee_trade, auto_delivery, ec,
   * cod,step的5种交易类型的数据；查询所有交易类型的数据，需要设置下面全部可选值。</span> 可选值： fixed(一口价)
   * auction(拍卖) step（分阶段付款，万人团，阶梯团订单） guarantee_trade(一口价、拍卖)
   * independent_simple_trade(旺店入门版交易) independent_shop_trade(旺店标准版交易)
   * auto_delivery(自动发货) ec(直冲) cod(货到付款) fenxiao(分销) game_equipment(游戏装备)
   * shopex_trade(ShopEX交易) netcn_trade(万网交易) external_trade(统一外部交易)
   * instant_trade (即时到账) b2c_cod(大商家货到付款) hotel_trade(酒店类型交易)
   * super_market_trade(商超交易), super_market_cod_trade(商超货到付款交易) taohua(桃花网交易类型）
   * waimai(外卖交易类型） nopaid（即时到帐/趣味猜交易类型） eticket(电子凭证) tmall_i18n（天猫国际）;
   * 注：guarantee_trade是一个组合查询条件，并不是一种交易类型，获取批量或单个订单中不会返回此种类型的订单。
   */
  private String              type;

  /**
   * 是否启用has_next的分页方式，如果指定true,则返回的结果中不包含总记录数，但是会新增一个是否存在下一页的的字段，<span style=
   * "color:red;font-weight: bold;">通过此种方式获取增量交易，效率在原有的基础上有80%的提升</span>。
   */
  private Boolean             useHasNext;

  public void setEndModified(Date endModified) {
    this.endModified = endModified;
  }

  public Date getEndModified() {
    return this.endModified;
  }

  public void setExtType(String extType) {
    this.extType = extType;
  }

  public String getExtType() {
    return this.extType;
  }

  public void setFields(String fields) {
    this.fields = fields;
  }

  public String getFields() {
    return this.fields;
  }

  public void setIsAcookie(Boolean isAcookie) {
    this.isAcookie = isAcookie;
  }

  public Boolean getIsAcookie() {
    return this.isAcookie;
  }

  public void setPageNo(Long pageNo) {
    this.pageNo = pageNo;
  }

  public Long getPageNo() {
    return this.pageNo;
  }

  public void setPageSize(Long pageSize) {
    this.pageSize = pageSize;
  }

  public Long getPageSize() {
    return this.pageSize;
  }

  public void setStartModified(Date startModified) {
    this.startModified = startModified;
  }

  public Date getStartModified() {
    return this.startModified;
  }

  public void setStatus(String status) {
    this.status = status;
  }

  public String getStatus() {
    return this.status;
  }

  public void setTag(String tag) {
    this.tag = tag;
  }

  public String getTag() {
    return this.tag;
  }

  public void setType(String type) {
    this.type = type;
  }

  public String getType() {
    return this.type;
  }

  public void setUseHasNext(Boolean useHasNext) {
    this.useHasNext = useHasNext;
  }

  public Boolean getUseHasNext() {
    return this.useHasNext;
  }

  public Long getTimestamp() {
    return this.timestamp;
  }

  public void setTimestamp(Long timestamp) {
    this.timestamp = timestamp;
  }

  public String getApiMethodName() {
    return "taobao.trades.sold.increment.get";
  }

  public Map<String, String> getTextParams() {
    TaobaoHashMap txtParams = new TaobaoHashMap();
    txtParams.put("end_modified", this.endModified);
    txtParams.put("ext_type", this.extType);
    txtParams.put("fields", this.fields);
    txtParams.put("is_acookie", this.isAcookie);
    txtParams.put("page_no", this.pageNo);
    txtParams.put("page_size", this.pageSize);
    txtParams.put("start_modified", this.startModified);
    txtParams.put("status", this.status);
    txtParams.put("tag", this.tag);
    txtParams.put("type", this.type);
    txtParams.put("use_has_next", this.useHasNext);
    if (this.udfParams != null) {
      txtParams.putAll(this.udfParams);
    }
    return txtParams;
  }

  public void putOtherTextParam(String key, String value) {
    if (this.udfParams == null) {
      this.udfParams = new TaobaoHashMap();
    }
    this.udfParams.put(key, value);
  }

  public Class<TradesSoldIncrementGetResponse> getResponseClass() {
    return TradesSoldIncrementGetResponse.class;
  }

  public void check() throws ApiRuleException {
    RequestCheckUtils.checkNotEmpty(endModified, "endModified");
    RequestCheckUtils.checkNotEmpty(fields, "fields");
    RequestCheckUtils.checkNotEmpty(startModified, "startModified");
  }

  public Map<String, String> getHeaderMap() {
    return headerMap;
  }
}
